package com.macgoo.game.util;

import com.sonalb.net.http.cookie.CookieJar;
import com.sonalb.net.http.cookie.MalformedCookieException;
import com.sonalb.net.http.cookie.RFC2965CookieParser;

public final class DataUtil {
	public static final CookieJar StringsToCookieJar(String str) {
		str = str.substring(2, str.length() - 2);
		CookieJar c = new CookieJar();
		if(str.indexOf("],[") == -1) {
			try {
				c.add(RFC2965CookieParser.parseSingleCookieV1(str, null, false));
			} catch (MalformedCookieException e) {
				e.printStackTrace();
				return c;
			}
			return c;
		} else {
			String[] temp = str.split("],[");
			for(String s : temp) {
				try {
					c.add(RFC2965CookieParser.parseSingleCookieV0(s, null, false));
				} catch (MalformedCookieException e) {
					e.printStackTrace();
					continue;
				}
			}
		}
		return c;
	}
}
